package org.example.ssh

import org.example.ssh.base.SSH
import org.example.ssh.base.SshCtx
import org.example.ssh.base.executeCmdPrint
import org.example.ssh.base.uploadDirectoryRecursive

suspend fun main() {
    val list = SSH.getGroup("dev_mysql-HK-3")
    SSH.execF(list) {
        DeployMysql().deploy(it)
    }
}
class DeployMysql {
    suspend fun deploy(sshCtx: SshCtx) {
//        executeCmdPrint(sshCtx.cli, "docker images")
//        return
        val sftp = sshCtx.cli.newSFTPClient()
        uploadDirectoryRecursive(sftp, "./配置/mysql/${sshCtx.cName}", "/home")
        println("上传成功")
//        executeCmdPrint(ssh, "cd $coturnDir && docker-compose -f docker-mysql.yml down")
        executeCmdPrint(sshCtx.cli, "cd /home/${sshCtx.cName} && docker-compose -f docker-mysql.yml up -d")

        executeCmdPrint(sshCtx.cli, "docker ps")
    }
}










